﻿-- 角色升级的一些处理
--lua script

--#include "data\config\quest\MiscQuest.lua" once
--#include "data\config\quest\EntrustReward.lua" once  							--除魔任务（天书任务、渡魔任务）
--#include "data\functions\player.lua" once -- 角色处理
--#include "data\functions\Activity\OpenServer\OpenServerSports.lua" once    	--开服竞技（2017.2）
--#include "data\functions\Activity\OpenServer\OpenServerPKRank.lua" once    	
--#include "data\functions\ActorEvent\SwingEquipHandler.lua" once
--#include "data\functions\Skill\SkillCommon.lua" once
--#include "data\functions\welfare\OfflineExpCopy.lua"  once  		--离线副本
--#include "data\functions\welfare\UpgradeGift.lua"  once  		--成长好礼
--#include "data\functions\welfare\LevelUpWelfare.lua"  once  		--等级福利
--#include "data\functions\mail\MailCommon.lua"  once  		--邮件事件

--[[新手等级保护buff
]]
function NewPlayerProtectBuff(sysarg, nowLevel)
	--[[
	if (nowLevel >= GlobalConfig.nNewPlayerProtectBuffLevelLimit and Actor.hasBuff(sysarg, 93, -1)) then
		Actor.delBuff(sysarg, 93, -1)
		Actor.sendTipmsg(sysarg, Lang.ScriptTips.pk00011, ttFlyTip)
	end
	]]
end


--[[
角色升级的处理
]]
EventCallDispatcher.ActorLevelUpHandler = function (sysarg, arg)
	local oldLevel = arg[2]
	local myLevel = Actor.getIntProperty(sysarg, PROP_CREATURE_LEVEL)	
	Skill_OnActorLevelUp( sysarg )
	--SendCSExtInfoToClient(sysarg)
	--OnLevelUpFullGemValue(sysarg)
	--需要通知前端打开登陆器了
	--OnCheckDownloadLauncher(sysarg,myLevel)
	--HeroOpenTips(sysarg)
	NewPlayerProtectBuff(sysarg, myLevel)			--处理新手保护buff
	
	--世界文明等级
	updateWorldCultureBuff(sysarg)
	
	--处理玩家等级提升
	OnPlayerLevelUp(sysarg, oldLevel)

	--除魔任务
	local myLevel = Actor.getIntProperty(sysarg, PROP_CREATURE_LEVEL)
	local myCircle = Actor.getIntProperty(sysarg, PROP_ACTOR_CIRCLE)
	if myLevel == BookQuestConfig.BookQuestLevel and myCircle == 0 then
		Actor.sendBookQuest(sysarg, BookQuestConfig.BookQuestId)
	end
		   
	OpenServerTriggleEvent(sysarg, enOpenServerId_Leveling, myLevel, myCircle)   --开服活动等级竞技
	OpenServerPKRankTriggleEvent(sysarg, enOpenServerRank_Leveling, myLevel, myCircle)
	OnMailEvent( sysarg, myCircle, myLevel )		--邮件事件
	UpgradeGiftLevelChange(sysarg, myCircle, myLevel) 	--成长好礼

	LevelUpWelfareLevelChange(sysarg, myCircle, myLevel) 	--等级福利

	OfflineExpActorLevelChange(sysarg)		--离线副本经验改变

	--激活翅膀
	if Actor.checkActorLevel(sysarg, SwingEquipConfig.givingSwing) then
		activeSwing(sysarg)
	end
end

--[[下载登陆器任务
function OnCheckDownloadLauncher( sysarg ,myLevel)

	for k, lv in ipairs(DownloadLauncherInfo.NoticeLv) do
		if lv == myLevel then
			local netPack = DataPack.allocPacket(sysarg, 6, 14)
			if netPack then
				DataPack.flush(netPack)
			end
			break
		end
	end
end
]]


EventCallDispatcher.registerEventCall(BaseTypes.ActorEventId.aeLevel, EventCallDispatcher.ActorLevelUpHandler)

